package org.linlinjava.litemall.db.service;

import com.github.pagehelper.PageHelper;
import org.linlinjava.litemall.db.dao.LitemallQualificationMapper;
import org.linlinjava.litemall.db.domain.LitemallQualification;
import org.linlinjava.litemall.db.domain.LitemallQualificationExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class LitemallQualificationService {
    @Resource
    LitemallQualificationMapper qualificationMapper;

    /**
     * @Description  获取全部资质
     * @Author Riko
     * @Date 2019/9/24
     **/
    public List<LitemallQualification> getAllQualification(){
        return qualificationMapper.selectByExample(new LitemallQualificationExample());
    }

    /**
     * @Description  根据主键List获取资质
     * @Author Riko
     * @Date 2019/9/24
     **/
    public List<LitemallQualification> selcetByBrand(List<Integer> idList) {
        LitemallQualificationExample example = new LitemallQualificationExample();
        example.or().andIdIn(idList);
        return qualificationMapper.selectByExample(example);
    }
    public void deleteById(Integer id) {
        qualificationMapper.deleteByPrimaryKey(id);
    }

    /**
     * 查所有:分页显示
     * @param page
     * @param size
     * @return
     */
    public List<LitemallQualification> querySelective(Integer page, Integer size) {
        LitemallQualificationExample example = new LitemallQualificationExample();
        PageHelper.startPage(page, size);
        return qualificationMapper.selectByExample(example);
    }

    /**
     * 增加 一个
     * @param qualification
     * @return
     */
    public int add(LitemallQualification qualification) {
        return qualificationMapper.insertSelective(qualification);
    }

    /**
     * 更新: 主键
     * @param qualification
     */
    public void updateById(LitemallQualification qualification) {
        qualificationMapper.updateByPrimaryKeySelective(qualification);
    }

    /**
     * 查:主键
     * @param qualificationId
     * @return
     */
    public LitemallQualification findById(Integer qualificationId) {
        return qualificationMapper.selectByPrimaryKey(qualificationId);
    }

}
